<template>
  <view class="popup">
    <view class="popupContent">
      <image src="@/static/images/huojia/exchangeResult/success-icon.png"></image>
      <view class="title">兑换成功</view>
      <view class="text">安全币支付成功，请领取商品</view>
      <view class="btn" @click="close">回到首页 ( {{ countDown }}s )</view>
    </view>
    <view class="popupBtn" @click="close">
      <image src="@/static/images/huojia/exchangeResult/close.png"></image>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      countDown: 5,
    };
  },
  mounted() {
    let time = setInterval(() => {
      this.countDown--;
      if (this.countDown == 0) {
        clearInterval(time);
        this.close();
      }
    }, 1000);
  },
  methods: {
    close() {
      this.$emit("close");
    },
  },
};
</script>

<style lang="scss" scoped>
.popup {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.7);
  .popupContent {
    position: relative;
    width: 356rpx;
    background: linear-gradient(179deg, #fde8e8 0%, #fff7df 19%, #ffffff 100%);
    box-shadow: inset 0rpx 1rpx 8rpx 0rpx #fdebea;
    border-radius: 45rpx;
    border: 2rpx solid rgba(255, 255, 255, 0.6);
    padding: 62.81rpx 23.44rpx 35.63rpx;
    line-height: 1;

    > image {
      position: absolute;
      top: -50.63rpx;
      right: 9.38rpx;
      width: 180rpx;
      height: 165rpx;
    }
    .title {
      font-weight: bold;
      font-size: 26rpx;
      color: #392d3a;
    }
    .text {
      margin-top: 33.75rpx;
      margin-bottom: 70.31rpx;
      font-size: 17rpx;
      color: #4a483b;
    }
    .btn {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 248rpx;
      height: 64rpx;
      margin: 0 auto;
      background: #fa6402;
      border-radius: 32rpx;

      font-weight: bold;
      font-size: 23rpx;
      color: #ffffff;
    }
  }
  .popupBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40rpx;
    height: 40rpx;
    margin-top: 45rpx;
    > image {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
